<?php
require_once(dirname(__FILE__).'/config.php');
CheckPurview('plus_语言包管理');
require_once(DEDEINC."/lang/language.map.inc");

$langdir=DEDEINC."/lang";
if(empty($filename))	$filename = '';
$filename = ereg_replace("[/\\]",'',$filename);

/*
编辑语言文件
*/
if($action == 'edit')
{
	if($filename == '' && $action == 'edit')
	{
		ShowMsg('未指定要编辑的文件', '-1');
		exit();
	}
	//读取文件内容
	//$content = htmlspecialchars(trim(file_get_contents($truePath.$filename)));
	if($action == 'edit')
	{
		
		$fp = fopen($langdir.'/'.$filename,'r');
		$content = fread($fp,filesize($langdir.'/'.$filename));
		fclose($fp);
	}

	include DEDEADMIN.'/templets/langfile_edit.htm';
	exit();
}
/*---------------------------
保存编辑的语言文件
--------------------------*/
else if($action == 'saveedit')
{
	if($filename == '')
	{
		ShowMsg('未指定要编辑的文件或文件名不合法', '-1');
		exit();
	}
	
	$truefile = $langdir.'/'.$filename;
	$content = stripslashes($content);
	$fp = fopen($truefile,'w');
	fwrite($fp, $content);
	fclose($fp);
	ShowMsg('成功修改语言文件', 'langfile_main.php');
	exit();
}else {
	if($lang=='') $lang = "gb2312";
$langfile=$langfile;
if ($lang=='gb2312') {
	$langpostion="简体中文";
}elseif ($lang=="en"){
	$langpostion="English";
}else {
	$langpostion="繁体中文";
}
if($langfile =='') {
require_once(DEDEINC."/lang/{$lang}.utf8.php");
}else{	
require_once(DEDEINC."/lang/{$langfile}");
}
include DedeInclude('templets/langfile_main.htm');
}
?>